﻿using GameProtocol;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using GameProtocol.dto;
using LOLServer.tool;

namespace LOLServer.logic.select
{
   public class SelectRoom:AbsMulitHandler, HandlerInterface
    {
       public ConcurrentDictionary<int, SelectModel> teamOne = new ConcurrentDictionary<int, SelectModel>();
       public ConcurrentDictionary<int, SelectModel> teamTwo = new ConcurrentDictionary<int, SelectModel>();

       public void Init(List<int> teamOne, List<int> teamTwo)
       {

           teamOne.Clear();
           teamTwo.Clear();
           foreach (int item in teamOne)
           {
               SelectModel select = new SelectModel();
               select.userId = item;
               select.name = getUser(item).name;
               select.hero = -1;
               select.enter = false;
               select.ready = false;
               this.teamOne.TryAdd(item, select);
           }
           foreach (int item in teamTwo)
           {
               SelectModel select = new SelectModel();
               select.userId = item;
               select.name = getUser(item).name;
               select.hero = -1;
               select.enter = false;
               select.ready = false;
               this.teamTwo.TryAdd(item, select);
           }
        
           //初始化完毕  开始定时任务  设定 30秒后没有进入选择界面的时候 直接解散此次匹配
           ScheduleUtil.Instance.schedule(delegate { 
            //30秒后判断进入情况 如果不是全员进入 解散房间
              
           
           }, 30 * 1000);
       }

       public void ClientClose(NetFrame.UserToken token, string error)
       {
           
       }

       public void MessageReceive(NetFrame.UserToken token, NetFrame.auto.SocketModel message)
       {
           
       }


       public override byte GetType()
       {
           return Protocol.TYPE_SELECT;
       }
    }
}
